package com.ysd.lis.service.bac.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.ysd.common.Result;
import com.ysd.lis.controller.lab.LabMaininfoController;
import com.ysd.lis.entity.PubEmployee;
import com.ysd.lis.entity.SysInterface;
import com.ysd.lis.entity.SysOrgDepartment;
import com.ysd.lis.entity.SysUser;
import com.ysd.lis.entity.bac.BacFlowDefResult;
import com.ysd.lis.entity.bac.BacTestResult;
import com.ysd.lis.entity.bac.BacTestWorkFlow;
import com.ysd.lis.entity.lab.*;
import com.ysd.lis.mapper.bac.BacFlowDefResultMapper;
import com.ysd.lis.mapper.bac.BacTestResultMapper;
import com.ysd.lis.mapper.lab.LabMaininfoMapper;
import com.ysd.lis.mapper.lab.LabRptmainMapper;
import com.ysd.lis.mapper.sys.SysInterfaceMapper;
import com.ysd.lis.request.UptedLabMainInfo;
import com.ysd.lis.request.lab.DefResultDto;
import com.ysd.lis.request.lab.DefResultParam;
import com.ysd.lis.request.lab.UptMainInfoTextChkDoctorDto;
import com.ysd.lis.service.SysBasDictDetailService;
import com.ysd.lis.service.bac.BacFlowDefResultService;
import com.ysd.lis.service.lab.LabMaininfoService;
import com.ysd.util.RedisUserManager;
import com.ysd.util.ToolsUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;


/**
 * <p>
 * 细菌描述性结果选项 服务实现类
 * </p>
 *
 * @author prs
 * @since 2025-02-10
 */
@Service
public class BacFlowDefResultServiceImpl extends ServiceImpl<BacFlowDefResultMapper, BacFlowDefResult> implements BacFlowDefResultService {
    private static final Logger logger = LoggerFactory.getLogger(BacFlowDefResultServiceImpl.class);

    @Autowired
    BacFlowDefResultMapper bacFlowDefResultMapper;
    @Autowired
    LabMaininfoMapper labMaininfoMapper;
    @Autowired
    BacTestResultMapper bacTestResultMapper;
    @Autowired
    SysBasDictDetailService sysBasDictDetailService;
    @Autowired
    LabRptmainMapper labRptmainMapper;
    @Autowired
    LabMaininfoService labMaininfoService;
    @Autowired
    SysInterfaceMapper sysInterfaceMapper;
    @Override
    public Result findFlowDefResultList(DefResultParam param) {
        MPJLambdaWrapper<BacFlowDefResult> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.selectAll(BacFlowDefResult.class);
        if (StringUtils.isNotBlank(param.getFlowNo())) {
            queryWrapper.eq(BacFlowDefResult::getFlowNo,param.getFlowNo());
        }

        queryWrapper.eq(BacFlowDefResult::getDelFlag, 0)
                .orderByAsc(BacFlowDefResult::getSeq);
        return Result.succ(1, "查询成功", bacFlowDefResultMapper.selectList(queryWrapper));
    }

    @Override
    public Result saveOrUpdateFlowDefResult(DefResultDto dto) {
        List<BacFlowDefResult> flowDefResultList = dto.getFlowDefResultList();
        boolean b = this.saveOrUpdateBatch(flowDefResultList);
        if(b){
            return Result.succ(1, "成功", null);
        }else {
            return Result.fail(400,"失败","");
        }
    }

    @Override
    public Result batchDeleteFlowDefResult(DefResultDto dto) {
        List<BacFlowDefResult> flowDefResultList = dto.getFlowDefResultList();
        List<String> ids = flowDefResultList.stream().map(BacFlowDefResult::getId).collect(Collectors.toList());
        boolean b = this.removeByIds(ids);
        if(b){
            return Result.succ(1, "删除成功", null);
        }else {
            return Result.fail(400,"删除失败","");
        }
    }

    @Override
    public Result getBacMaininfoByReqNo(DefResultParam param) {
        String reqNo = param.getReqNo();
        String rptGroup = param.getRptGroup();
        //根据reqno和rptgroup查询主表信息
        MPJLambdaWrapper<LabMaininfo> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.selectAll(LabMaininfo.class);
        queryWrapper.selectAs(LabSampleType::getSampleTypeName, LabMaininfo::getSampleTypeNa);
        queryWrapper.selectAs(SysOrgDepartment::getName, LabMaininfo::getReqDeptNa);
        queryWrapper.selectAs("req", PubEmployee::getName, LabMaininfo::getReqDoctorNa);
        queryWrapper.selectAs("test", SysUser::getRealname, LabMaininfo::getTestDoctorNa);
        queryWrapper.selectAs("chk", SysUser::getRealname, LabMaininfo::getChkDoctorNa);
        queryWrapper.selectAs("rechk", SysUser::getRealname, LabMaininfo::getReChkDoctorNa);
        queryWrapper.selectAs("prt", SysUser::getRealname, LabMaininfo::getPrintDoctorNa);
        queryWrapper.selectAs("sampl", SysUser::getRealname, LabMaininfo::getSamplingDoctorNa);
        queryWrapper.selectAs("signer", SysUser::getRealname, LabMaininfo::getSignerDoctorNa);
        queryWrapper.selectAs("rptgrp", LabRptGroup::getRptGroupName, LabMaininfo::getRptGroupNa);
        queryWrapper.selectAs("reqm", LabReqMainQuery::getId, LabMaininfo::getReqMainId);
        queryWrapper.selectAs("flo", BacTestWorkFlow::getWorkFlowNa, LabMaininfo::getWorkFlowNa);
        queryWrapper.selectAs("flo", BacTestWorkFlow::getWorkFlowNo, LabMaininfo::getWorkFlowNo);

        queryWrapper.leftJoin(LabSampleType.class, p -> p.eq(LabSampleType::getSampleTypeCode, LabMaininfo::getSampleType).eq(LabSampleType::getDelFlag, 0));
        queryWrapper.leftJoin(SysOrgDepartment.class, p -> p.eq(SysOrgDepartment::getCode, LabMaininfo::getReqDept).eq(SysOrgDepartment::getDelFlag, 0));
        queryWrapper.leftJoin(PubEmployee.class, "req", p -> p.eq(PubEmployee::getCode, LabMaininfo::getReqDoctor).eq(PubEmployee::getDelFlag, 0));
        queryWrapper.leftJoin(SysUser.class, "test", p -> p.eq(SysUser::getUsername, LabMaininfo::getTestDoctor).eq(SysUser::getDelFlag, 0).isNotNull(SysUser::getUsername).ne(SysUser::getUsername, ""));
        queryWrapper.leftJoin(SysUser.class, "chk", p -> p.eq(SysUser::getUsername, LabMaininfo::getChkDoctor).eq(SysUser::getDelFlag, 0).isNotNull(SysUser::getUsername).ne(SysUser::getUsername, ""));
        queryWrapper.leftJoin(SysUser.class, "rechk", p -> p.eq(SysUser::getUsername, LabMaininfo::getReChkDoctor).eq(SysUser::getDelFlag, 0).isNotNull(SysUser::getUsername).ne(SysUser::getUsername, ""));
        queryWrapper.leftJoin(SysUser.class, "prt", p -> p.eq(SysUser::getUsername, LabMaininfo::getPrintDoctor).eq(SysUser::getDelFlag, 0).isNotNull(SysUser::getUsername).ne(SysUser::getUsername, ""));
        queryWrapper.leftJoin(SysUser.class, "sampl", p -> p.eq(SysUser::getUsername, LabMaininfo::getSamplingDoctor).eq(SysUser::getDelFlag, 0).isNotNull(SysUser::getUsername).ne(SysUser::getUsername, ""));
        queryWrapper.leftJoin(SysUser.class, "signer", p -> p.eq(SysUser::getUsername, LabMaininfo::getSignerDoctor).eq(SysUser::getDelFlag, 0).isNotNull(SysUser::getUsername).ne(SysUser::getUsername, ""));
        queryWrapper.leftJoin(LabRptGroup.class, "rptgrp", p -> p.eq(LabRptGroup::getRptGroup, LabMaininfo::getRptGroup).eq(LabRptGroup::getDelFlag, 0));
        queryWrapper.leftJoin(LabReqMainQuery.class, "reqm", p -> p.eq(LabReqMainQuery::getReqNo, LabMaininfo::getReqNo).eq(LabReqMainQuery::getDelFlag, 0));
        queryWrapper.leftJoin(BacTestWorkFlow.class, "flo", p -> p.eq(BacTestWorkFlow::getRptGroup, LabMaininfo::getRptGroup).eq(BacTestWorkFlow::getSampleNo, LabMaininfo::getSampleNo).eq(BacTestWorkFlow::getSampleda, LabMaininfo::getSampleda).eq(BacTestWorkFlow::getDelFlag, 0));

        queryWrapper.eq(LabMaininfo::getDelFlag, 0)
                .eq(LabMaininfo::getRptGroup, rptGroup)
                .eq(LabMaininfo::getReqNo, reqNo);

        List<LabMaininfo> labMaininfos = labMaininfoMapper.selectList(queryWrapper);
        if(ToolsUtils.isNotEmpty(labMaininfos)){
            LabMaininfo maininfo = labMaininfos.get(0);
            BigDecimal isChk = maininfo.getIsChk();
            if(ToolsUtils.isEmpty(isChk)|| isChk.intValue() < 2 ){
                //获取数据字典(病人类型、性别、证件类型)
                List<Map<String, Object>> patTypeList = (List<Map<String, Object>>) sysBasDictDetailService.getSysBasDictList("PATTYPE").getData();
                List<Map<String, Object>> sexList = (List<Map<String, Object>>) sysBasDictDetailService.getSysBasDictList("Sex").getData();
                List<Map<String, Object>> idTypeList = (List<Map<String, Object>>) sysBasDictDetailService.getSysBasDictList("002").getData();
                if (ToolsUtils.isNotEmpty(maininfo.getPatType()) && CollectionUtils.isNotEmpty(patTypeList)) {
                    patTypeList.stream().filter(a -> a.get("code").equals(maininfo.getPatType())).findFirst().ifPresent(stringObjectMap -> maininfo.setPatTypeNa((String) stringObjectMap.get("name")));
                }
                if (ToolsUtils.isNotEmpty(maininfo.getSex()) && CollectionUtils.isNotEmpty(sexList)) {
                    sexList.stream().filter(a -> a.get("code").equals(maininfo.getSex())).findFirst().ifPresent(stringObjectMap -> maininfo.setSexNa((String) stringObjectMap.get("name")));
                }
                if (ToolsUtils.isNotEmpty(maininfo.getIdType()) && CollectionUtils.isNotEmpty(idTypeList)) {
                    idTypeList.stream().filter(a -> a.get("code").equals(maininfo.getIdType())).findFirst().ifPresent(stringObjectMap -> maininfo.setIdTypeNa((String) stringObjectMap.get("name")));
                }

                Map<String,Object> returnMap = new HashMap<>();
                returnMap.put("labMaininfo",maininfo);

                //根据方案获取默认的阴性结果
                String workFlowNo = maininfo.getWorkFlowNo();

                MPJLambdaWrapper<BacFlowDefResult> queryWrapper1 = new MPJLambdaWrapper<>();
                queryWrapper1.selectAll(BacFlowDefResult.class);
                if (StringUtils.isNotBlank(workFlowNo)) {
                    queryWrapper1.eq(BacFlowDefResult::getFlowNo,workFlowNo);
                }

                queryWrapper1.eq(BacFlowDefResult::getDelFlag, 0)
                        .orderByAsc(BacFlowDefResult::getSeq);
                List<BacFlowDefResult> flowDefResultList = bacFlowDefResultMapper.selectList(queryWrapper1);
                if(ToolsUtils.isNotEmpty(flowDefResultList)){
                    //根据默认结果生成阴性结果
                    List<BacTestResult> addbacTestResults = new ArrayList<>();
                    for (int i = 0; i < flowDefResultList.size(); i++){
                        BacFlowDefResult bacFlowDefResult = flowDefResultList.get(i);

                        BacTestResult bacTestResult = new BacTestResult();
                        bacTestResult.setSampleda(maininfo.getSampleda());
                        bacTestResult.setRptGroup(rptGroup);
                        bacTestResult.setSampleNo(maininfo.getSampleNo());
                        bacTestResult.setIsolateNum("Def"+String.valueOf(i+1));
                        String defNa = bacFlowDefResult.getDefNa();
                        //defNa是否包含[day]，如果不包含直接赋值，如果包含则获取当前时间与testTime作比较查看过了多少天
                        if(defNa.contains("[day]")){
                            Timestamp testTime = maininfo.getTestTime();
                            if(ToolsUtils.isNotEmpty(testTime)){
                                try {


                                    // 将Timestamp转换为LocalDate
                                    LocalDate startDate = testTime.toLocalDateTime().toLocalDate();
                                    LocalDate endDate = new Timestamp(new Date().getTime()).toLocalDateTime().toLocalDate();

                                    // 计算两个日期之间的天数差
                                    long daysBetween = ChronoUnit.DAYS.between(startDate, endDate);
                                    defNa = defNa.replace("[day]",String.valueOf(daysBetween));
                                    bacTestResult.setGermNa(defNa);
                                }catch (Exception e){
                                    e.printStackTrace();
                                }
                            }
                        }else {
                            bacTestResult.setGermNa(bacFlowDefResult.getDefNa());
                        }
                        bacTestResult.setOperateDate(new Timestamp(new Date().getTime()));
                        SysUser sysUser = RedisUserManager.getUser();
                        if(ToolsUtils.isNotEmpty(sysUser)){
                            bacTestResult.setOperateUserNo(sysUser.getRealname());
                        }
                        bacTestResult.setTestFlowNo(workFlowNo);
                        bacTestResult.setTestNodeNo("JINGJIAN");
                        bacTestResult.setIsAlarm(false);
                        bacTestResult.setIsDrugAlarm(false);
                        bacTestResult.setIsContagion(false);
                        addbacTestResults.add(bacTestResult);

                    }
                    returnMap.put("addbacTestResults",addbacTestResults);

                }


                //根据三个维度查询BAC_RPTRESULT
                String sampleNo = maininfo.getSampleNo();
                Timestamp sampleda = maininfo.getSampleda();
                MPJLambdaWrapper<BacTestResult> queryWrapper2 = new MPJLambdaWrapper<>();
                queryWrapper2.eq(BacTestResult::getDelFlag, 0);

                if (!BeanUtil.isEmpty(sampleda)) {
                    Timestamp startTime = Timestamp.valueOf(sampleda.toString().substring(0, 10) + " 00:00:00");
                    Timestamp endTime = Timestamp.valueOf(sampleda.toString().substring(0, 10) + " 23:59:59");
                    queryWrapper2.ge(BacTestResult::getSampleda, startTime);
                    queryWrapper2.le(BacTestResult::getSampleda, endTime);
                }
                queryWrapper2.eq(StringUtils.isNotBlank(rptGroup), BacTestResult::getRptGroup, rptGroup);
                queryWrapper2.eq(StringUtils.isNotBlank(sampleNo), BacTestResult::getSampleNo, sampleNo);
                queryWrapper2.orderByAsc(BacTestResult::getCreateTime);
                List<BacTestResult> bacTestResultList = bacTestResultMapper.selectList(queryWrapper2);


                returnMap.put("bacTestResultList",bacTestResultList);

                return Result.succ(1, "查询成功", returnMap);


            }else {
                return Result.fail("已审核");
            }



        }else {
            return Result.fail("未查询到数据");
        }


    }

    @Override
    public Result batchDeleteBacTestResult(DefResultDto dto) {
        List<BacTestResult> bacTestResultList = dto.getBacTestResultList();
        if(ToolsUtils.isNotEmpty(bacTestResultList)){
            for (int i = 0; i < bacTestResultList.size(); i++){
                BacTestResult bacTestResult = bacTestResultList.get(i);
                bacTestResult.setDelFlag(1);
                bacTestResultMapper.updateById(bacTestResult);
            }

        }
        return Result.succ("删除成功");

    }

    @Override
    public Result batchSaveBacTestResult(DefResultDto dto) {
        List<BacTestResult> bacTestResultList = dto.getBacTestResultList();
        if(ToolsUtils.isNotEmpty(bacTestResultList)){
            for (int i = 0; i < bacTestResultList.size(); i++){
                BacTestResult bacTestResult = bacTestResultList.get(i);
                bacTestResultMapper.insert(bacTestResult);

            }

        }
        return Result.succ(bacTestResultList);
    }

    @Override
    public Result batchChkBacTestResult(DefResultDto dto) {
        List<BacTestResult> bacTestResultList = dto.getBacTestResultList();
        if(ToolsUtils.isNotEmpty(bacTestResultList)){
            for (int i = 0; i < bacTestResultList.size(); i++){
                BacTestResult bacTestResult = bacTestResultList.get(i);
                bacTestResultMapper.insert(bacTestResult);
            }
        }

        //审核
        List<UptMainInfoTextChkDoctorDto> uptMainInfoTextChkDoctorDtoList = dto.getUptMainInfoTextChkDoctorDtoList();
        List<LabMaininfo> maininfoList = new ArrayList<>();
        for(UptMainInfoTextChkDoctorDto uptMainInfoTextChkDoctorDto : uptMainInfoTextChkDoctorDtoList){
            if(ToolsUtils.isNotEmpty(uptMainInfoTextChkDoctorDto)){
                Result result = labMaininfoService.updateBacTestChkDoctorAfterAuth(uptMainInfoTextChkDoctorDto);
                UptedLabMainInfo data = (UptedLabMainInfo)result.getData();
                LabMaininfo curMainInfo = data.getCurMainInfo();
                maininfoList.add(curMainInfo);

            }
        }

        Map<String,Object> returnMap = new HashMap<>();
        returnMap.put("maininfoList",maininfoList);
        returnMap.put("addTestReulstList",bacTestResultList);

        return Result.succ(returnMap);
    }

    @Override
    public Result batchUnChkBacTestResult(DefResultDto dto) throws JsonProcessingException {
        List<LabMaininfo> labMaininfoList = dto.getLabMaininfoList();
        List<LabMaininfo> returnList = new ArrayList<>();
        if(ToolsUtils.isNotEmpty(labMaininfoList)){
            for (LabMaininfo labMaininfo : labMaininfoList){
                Result result = labMaininfoService.unChkBacMainInfo(labMaininfo);
                if (!BeanUtil.isEmpty(labMaininfo.getIsChk()) && labMaininfo.getIsChk().equals(new BigDecimal(2))) {
                    //假删掉报告单
                    LambdaQueryWrapper<LabRptmain> lambdaQueryWrapper = new LambdaQueryWrapper<>();
                    lambdaQueryWrapper
                            .eq(LabRptmain::getRptGroup, labMaininfo.getRptGroup())
                            .eq(LabRptmain::getSampleda, labMaininfo.getSampleda())
                            .eq(LabRptmain::getSampleNo, labMaininfo.getSampleNo())
                            .eq(LabRptmain::getDelFlag, 0);
                    labRptmainMapper.delete(lambdaQueryWrapper);
                    //调用发送微生物报告接口
                    SysUser sysUser = RedisUserManager.getUser();
                    LambdaQueryWrapper<SysInterface> wrapper = new LambdaQueryWrapper<>();
                    wrapper.eq(SysInterface::getDelFlag, 0);
                    wrapper.eq(SysInterface::getIsEnable, 1);
                    wrapper.eq(SysInterface::getOrgId, sysUser.getOrgId());
                    List<SysInterface> sysInterfaces = sysInterfaceMapper.selectList(wrapper);
                    List<String> collect = sysInterfaces.stream().filter(o -> Objects.nonNull(o) && org.apache.commons.lang3.StringUtils.isNotBlank(o.getInterfaceUrl())).map(SysInterface::getInterfaceUrl).distinct().collect(Collectors.toList());
                    //标本消申
                    if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(collect)) {
                        /*发布报告相关*/
                        for (String webUrl : collect) {
                            //消审走报告发布传delete
//                            Map releaseReportMap = new HashMap();
//                            String releaseReport = webUrl + "/public/cancleWswReport";
//                            releaseReportMap.put("orgId", sysUser.getOrgId());
//                            releaseReportMap.put("mainInfoId", labMaininfo.getId());
//                            HttpUtil.createPost(releaseReport).setConnectionTimeout(3000).body(JSONUtil.toJsonStr(releaseReportMap)).contentType("application/json").execute().body();

                            //消审走报告发布传delete
                            Map releaseReportMap1 = new HashMap();
                            String releaseReport1 = webUrl + "/public/releaseWswReport";
                            releaseReportMap1.put("orgId", labMaininfo.getOrgId());
                            releaseReportMap1.put("mainInfoId", labMaininfo.getId());
                            releaseReportMap1.put("deleteFlag", "1");
                            String release = HttpUtil.createPost(releaseReport1).setConnectionTimeout(3000).body(JSONUtil.toJsonStr(releaseReportMap1)).contentType("application/json").execute().body();
                            logger.info("发布报告返回值:\n" + release);
                            try {
                                JSONObject releaseObject = new JSONObject(release);
                                JSONObject releaseStatus = releaseObject.getJSONObject("status");
                                String releaseCode = releaseStatus.get("code").toString();
                                if (!"400".equals(releaseCode)) {
                                    String updateUrl = webUrl + "/public/updateReportStatus";
                                    Map<String, Object> updateMap = new HashMap<>();
                                    updateMap.put("status", "99");//消审
                                    updateMap.put("reqNo", labMaininfo.getReqNo());
                                    updateMap.put("patType", labMaininfo.getPatType());
                                    updateMap.put("chkDoctor", labMaininfo.getChkDoctor());
                                    updateMap.put("testDoctor", labMaininfo.getTestDoctor());
                                    updateMap.put("patType", labMaininfo.getPatType());
                                    updateMap.put("samplingTime", BeanUtil.isEmpty(labMaininfo.getSamplingTime()) ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(labMaininfo.getSamplingTime()));
                                    updateMap.put("signTime", BeanUtil.isEmpty(labMaininfo.getSignTime()) ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(labMaininfo.getSignTime()));
                                    updateMap.put("operateTime", BeanUtil.isEmpty(labMaininfo.getTestTime()) ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(labMaininfo.getTestTime()));
                                    updateMap.put("reportTime", BeanUtil.isEmpty(labMaininfo.getChkTime()) ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(labMaininfo.getChkTime()));
                                    updateMap.put("orgId", labMaininfo.getOrgId());
                                    updateMap.put("username", sysUser.getUsername());
                                    updateMap.put("realname", sysUser.getRealname());
                                    updateMap.put("id", labMaininfo.getId());
                                    HttpUtil.createPost(updateUrl).setConnectionTimeout(3000).body(JSONUtil.toJsonStr(updateMap)).contentType("application/json").execute().body();
                                    //消审走报告发布需要撤销掉报告单(伊通需要)
                                    Map releaseReportMap2 = new HashMap();
                                    String zfReportUrl = webUrl + "/public/zfReleaseWswReport";
                                    releaseReportMap2.put("orgId", labMaininfo.getOrgId());
                                    releaseReportMap2.put("mainInfoId", labMaininfo.getId());
                                    HttpUtil.createPost(zfReportUrl).setConnectionTimeout(3000).body(JSONUtil.toJsonStr(releaseReportMap2)).contentType("application/json").execute().body();
                                }
                            } catch (Exception e) {
                                logger.info("发布报告返回值:\n" + release);
                            }
//                            String releaseReportHL7 = webUrl + "/cancleReport";
//                            HttpUtil.createPost(releaseReportHL7).setConnectionTimeout(3000).body(JSONUtil.toJsonStr(releaseReportMap)).contentType("application/json").execute().body();
                        }
                    }
                }
                Map<String, Object> status = result.getStatus();
                int code = (int)status.get("code");
                if (code==1||code ==200) {
                    LabMaininfo data = (LabMaininfo) result.getData();
                    returnList.add(data);
                }

            }
        }
        return Result.succ(1, "取消成功", returnList);
    }
}
